<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/
      思路：
    */
    function maxSlidingWindow(nums, k) {
      let len = nums.length
      if (!len) return []
      if (len === 1) return nums

      let res = []
      let left = 0
      let right = k - 1

      while (right <= len - 1) {
        let max = nums[left]
        for (let i = left + 1; i <= right; i++) {
          if (nums[i] > max)  max = nums[i]
        }
        res.push(max)
        left++
        right++
      }
      return res
    }
  </script>
</body>
</html>